$(function(){
	var ap = new AjaxOperator();
    var manager = new CustomerManager($("#content"));
    //初始化页面数据
    manager.findAll();
    
    //增加用户
    $("#add").on("click",function(e){
        var name = $("#form input[name='name']").val();
        var sex = $("#form input[name='sex']:checked").val();
        var salary=$("#form input[name='salary']").val();
        var birth = $("#form input[name='birth']").val();
        var customer = {name:name,sex:sex,salary:salary,birth:birth};
        e.preventDefault();
        manager.addCustomer(customer);
    });
    
  //更新用户
    $("#update").on("click",function(e){
    	var id = $("#updateModal input[name='id']").val();
    	var name = $("#updateModal input[name='name']").val();
    	var salary = $("#updateModal input[name='salary']").val();
        var sex = $("#updateModal input[name='sex']:checked").val();
    	var birth = $("#updateModal input[name='birth']").val();
    	var customer = {id:id,name:name,sex:sex,salary:salary,birth:birth};
    	manager.updateCustomer(customer);
    });
});